home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / sun / awt / macos / MChoicePeer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  1.8 KB  |  65 lines

  1. package sun.awt.macos;
  2.  
  3. import java.awt.Choice;
  4. import java.awt.Dimension;
  5. import java.awt.Event;
  6. import java.awt.FontMetrics;
  7. import java.awt.peer.ChoicePeer;
  8.  
  9. class MChoicePeer extends MComponentPeer implements ChoicePeer, ActionComponent {
  10.    int mActualMenuContents;
  11.  
  12.    public MChoicePeer(Choice var1) {
  13.       super(var1);
  14.    }
  15.  
  16.    native void create(MComponentPeer var1);
  17.  
  18.    public native void select(int var1);
  19.  
  20.    void initialize() {
  21.       Choice var1 = (Choice)super.target;
  22.       int var2 = var1.countItems();
  23.  
  24.       for(int var3 = 0; var3 < var2; ++var3) {
  25.          this.addItem(var1.getItem(var3), var3);
  26.       }
  27.  
  28.       this.select(var1.getSelectedIndex());
  29.       super.initialize();
  30.    }
  31.  
  32.    public Dimension minimumSize() {
  33.       FontMetrics var1 = ((MComponentPeer)this).getFontMetrics(super.target.getFont());
  34.       Choice var2 = (Choice)super.target;
  35.       int var3 = 0;
  36.  
  37.       for(int var4 = var2.countItems(); var4-- > 0; var3 = Math.max(var1.stringWidth(var2.getItem(var4)), var3)) {
  38.       }
  39.  
  40.       return new Dimension(40 + var3, var1.getHeight() + 4);
  41.    }
  42.  
  43.    public native void addItem(String var1, int var2);
  44.  
  45.    public native void remove(int var1);
  46.  
  47.    public void action(int var1) {
  48.       Choice var2 = (Choice)super.target;
  49.       var2.select(var1);
  50.       super.target.postEvent(new Event(super.target, 1001, var2.getItem(var1)));
  51.    }
  52.  
  53.    public void action() {
  54.       System.err.println("Internal AWT error");
  55.    }
  56.  
  57.    public void action(boolean var1) {
  58.       System.err.println("Internal AWT error");
  59.    }
  60.  
  61.    public void handleAction(int var1) {
  62.       InterfaceThread.postInterfaceEvent(super.target, var1);
  63.    }
  64. }
  65.